# ICEMGenerator - 高效的ICEM CFD网格划分Replay Script生成工具
# 案例说明：创建管式反应器

import os
from ICEMGenerator import create_circular, create_cylinder, create_elbow_pipe, Part, Block, replay_all, init_all_Id

init_all_Id(0)

# 创建几何对象
reactor_main = create_circular(r = (0.2, 0.2, 1, 1, 0.2, 0.2), h = (1, 2, 8, 0.5, 1), axis = 'y', top_filled = False, name = 'FLUID')
elbow_pipe = create_elbow_pipe(rb = 0.2, rt = 0.5, yb = 12.5, xt = 0.5, yt = 12.5, axis_b = 'y', axis_t = 'z', angle_start_t = 90, angle_end_t = 180, name = 'elbow')
prolonged_pipe = create_cylinder(r = 0.2, h = 1.5, x = 0.5, y = 13, axis = 'x', bottom_filled = False, name = 'prolonged')
reactor_main.join((elbow_pipe, prolonged_pipe))
reactor_main.setAsFinal()

# 给定边界条件
fluid = Part((reactor_main,), 'FLUID', 'FLUID')
inlet = Part((reactor_main.getSurface('circle_bottom'),), 'VELI', 'INLET')
outlet = Part((prolonged_pipe.getSurface('circle_top'),), 'PRESO', 'OUTLET')
wall = Part.wallFromRemainSurfaces()

# 创建块
FB = Block(parts_inside = (fluid,), parts_boundary = (inlet, outlet, wall), name = 'FB', dimension = 3, max_element_size = 0.1)

f = open('tube_reactor.rpl', 'w')
f.write(replay_all('E:/python/ICEMGenerator/demo/tube_reactor', 'fb'))
f.close()
os.system('notepad tube_reactor.rpl')